home *** CD-ROM | disk | FTP | other *** search
- onClipEvent(enterFrame){
- function doexplode()
- {
- myColor.setTransform(myColorNormal);
- this.gotoAndStop("death");
- }
- function dorespawn()
- {
- currentdamage = 0;
- hitted = false;
- flashing = false;
- timerdamage = 0;
- death = false;
- this.gotoAndStop("standing");
- idle = true;
- attack = preattack = attacking = false;
- _X = xi;
- _Y = _root.mapa._y - yi - heroe.vscrollspeed;
- shoot = new Sound();
- shoot.attachSound("barrelshoot");
- }
- function drawframe()
- {
- if(idle)
- {
- this.gotoAndStop("standing");
- }
- if(attacking)
- {
- this.gotoAndStop("attack");
- }
- }
- xi -= heroe.scrollspeed;
- _X = _X - heroe.scrollspeed;
- _Y = _root.mapa._y - yi;
- _visible = false;
- hitable = this.hitTest(_parent.mascara);
- if(hitable)
- {
- _visible = true;
- if(this.sprite.hotzone.hitTest(heroe.sprite.hotzone))
- {
- heroe.damage = 3;
- heroe.hitted = true;
- }
- if(this.sprite.hotzone.hitTest(_parent.shoot1) && hitable)
- {
- hitted = true;
- _root.shoot1.impact = true;
- _root.hitted.start();
- }
- if(timerdamage == 0 && hitted)
- {
- timerdamage = FLASHTIME;
- currentdamage += DAMAGE;
- }
- if(timerdamage > 0)
- {
- flashing = true;
- timerdamage % 3 != 0 ? myColor.setTransform(myColorNormal) : myColor.setTransform(myColorTransform);
- timerdamage--;
- }
- if(flashing && timerdamage == 0)
- {
- flashing = false;
- myColor.setTransform(myColorNormal);
- hitted = false;
- }
- if(currentdamage >= MAXDAMAGE)
- {
- myColor.setTransform(myColorTransform);
- death = true;
- delete shoot;
- }
- if(death)
- {
- _root.shoot1.impact = false;
- doexplode();
- }
- }
- if(!death)
- {
- if(idle)
- {
- if(Math.abs(heroe._x - _X) <= 140 && Math.abs(heroe._y - _Y) <= 220)
- {
- attack = attacking = false;
- idle = false;
- preattack = true;
- timer = DELAY;
- }
- }
- if(preattack)
- {
- timer--;
- if(!timer)
- {
- preattack = false;
- attack = true;
- }
- }
- if(attack && !attacking)
- {
- attacking = true;
- this.attachMovie("bullet","b1",1);
- this.attachMovie("bullet","b2",2);
- shoot.start();
- b1.control.dx = SPEED;
- b1.control.dy = -1 * SPEED;
- b1._x = -12;
- b1._y = -14;
- b2.control.dx = -1 * SPEED;
- b2.control.dy = -1 * SPEED;
- b2._x = 12;
- b2._y = -14;
- }
- if(attacking)
- {
- if(!b1.hitTest(_root.mascara) && !b2.hitTest(_root.mascara))
- {
- attacking = attack = preattack = false;
- idle = true;
- }
- }
- drawframe();
- }
- else if(Math.abs(heroe._x - _X) >= 200 || Math.abs(heroe._y - _Y) >= 200)
- {
- dorespawn();
- }
- }
-